package com.project.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.project.bean.RoleBean;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.context.annotation.Bean;

import java.util.List;

@Mapper
public interface IRoleMapper extends BaseMapper<RoleBean> {
    /**
     * 根据用户id查询角色集合
     * @param userId 用户id
     * @return 角色集合
     */
    List<RoleBean> findByUserId(Integer userId);
    void addGrade(@Param("roleId") Integer roleId, @Param("gradeIdArr") Integer[] gradeIdArr);
    /**
     * 根据角色id删除用户关系
     * @param roleId 角色id
     */
    @Delete("delete from t_user_role where fk_roleId = #{roleId}")
    void delRoleUser(Integer roleId);

    /**
     * 根据角色id删除权限关系
     * @param roleId 角色id
     */
    @Delete("delete from t_role_grade where fk_roleId = #{roleId}")
    void delRoleGrade(Integer roleId);
}
